//
//  QQFriendGroup.swift
//  QQFriend
//
//  Created by zhang on 16/1/10.
//  Copyright © 2016年 jin. All rights reserved.
//

import UIKit
//好友分组类
class QQFriendGroup: NSObject {
    var friends:[QQFriend] = []//存放qq好友对象数组
    var name:NSString!//分组名称
    var online:NSNumber!//分组在线人数
    var hideGroup:Bool = true//是否隐藏，默认是隐藏的
    //快速plist文件中初始化对象数组
    class func instanceWithFile()->[QQFriendGroup]
    {
        let path = NSBundle.mainBundle().pathForResource("friends", ofType: "plist")
        let data = NSArray(contentsOfFile: path!)
        var qqFriendGroups:[QQFriendGroup] = []
        for var i = 0;i < data!.count;i++
        {
            let qqFriendGroupTemp = QQFriendGroup(dic: data![i] as! NSDictionary)
            qqFriendGroups.append(qqFriendGroupTemp)
        }
        return qqFriendGroups
    }
    //快速实例化方法
    convenience init(dic:NSDictionary) {
        self.init()
        self.name = dic["name"] as! NSString
        self.online = dic["online"] as! NSNumber
        let friendsData = dic["friends"] as! NSArray
        for var i = 0;i < friendsData.count;i++
        {
            let qqFriend:QQFriend! = QQFriend(dic: friendsData[i] as! [String : AnyObject])
            self.friends.append(qqFriend)
        }
    }
}
